<template>
  <div id="app" class="max">
    <router-view/>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  name: 'App',
  mounted (){
    this.init()
  },
  methods: {
    init (){
      this.$store.commit('HISTORY')
      // 获取本地持久化的主题名称
      this.$store.commit('LOCAL', { theme: undefined })
      // 将主题颜色变量设置好
      const style = this.themes[this.theme]
      for (const colorName in style){
        document.body.style.setProperty(colorName, style[colorName])
      }
    }
  },
  computed: {
    ...mapState({
      theme: state => state.user.theme,
      themes: state => state.user.themes
    })
  }
}

</script>

<style lang="less">

</style>
